home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 April: Mac OS SDK / Dev.CD Apr 99 SDK1.toast / Development Kits / Interfaces&Libraries / Universal / Interfaces / PInterfaces / DeskBus.p < prev    next >
Encoding:
Text File  |  1998-08-17  |  6.9 KB  |  205 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        DeskBus.p
  3.  
  4.      Contains:    Apple Desktop Bus (ADB) Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1987-1998 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. }
  17. {$IFC UNDEFINED UsingIncludes}
  18. {$SETC UsingIncludes := 0}
  19. {$ENDC}
  20.  
  21. {$IFC NOT UsingIncludes}
  22.  UNIT DeskBus;
  23.  INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED __DESKBUS__}
  27. {$SETC __DESKBUS__ := 1}
  28.  
  29. {$I+}
  30. {$SETC DeskBusIncludes := UsingIncludes}
  31. {$SETC UsingIncludes := 1}
  32.  
  33. {$IFC UNDEFINED __MACTYPES__}
  34. {$I MacTypes.p}
  35. {$ENDC}
  36. {$IFC UNDEFINED __MIXEDMODE__}
  37. {$I MixedMode.p}
  38. {$ENDC}
  39.  
  40.  
  41. {$PUSH}
  42. {$ALIGN MAC68K}
  43. {$LibExport+}
  44.  
  45. {$IFC TARGET_OS_MAC }
  46.  
  47. TYPE
  48.     ADBAddress                            = SInt8;
  49. {$IFC TYPED_FUNCTION_POINTERS}
  50.     ADBCompletionProcPtr = PROCEDURE(buffer: Ptr; refCon: Ptr; command: LONGINT);
  51. {$ELSEC}
  52.     ADBCompletionProcPtr = Register68kProcPtr;
  53. {$ENDC}
  54.  
  55. {$IFC TYPED_FUNCTION_POINTERS}
  56.     ADBDeviceDriverProcPtr = PROCEDURE(devAddress: SInt8; devType: SInt8);
  57. {$ELSEC}
  58.     ADBDeviceDriverProcPtr = Register68kProcPtr;
  59. {$ENDC}
  60.  
  61. {
  62.     TempADBServiceRoutineUPP is needed because of circular definition of
  63.     ADBServiceRoutineProcPtr and ADBServiceRoutineUpp depending on each other.
  64. }
  65.     TempADBServiceRoutineUPP            = ProcPtr;
  66. {$IFC TYPED_FUNCTION_POINTERS}
  67.     ADBServiceRoutineProcPtr = PROCEDURE(buffer: Ptr; completionProc: TempADBServiceRoutineUPP; refCon: Ptr; command: LONGINT);
  68. {$ELSEC}
  69.     ADBServiceRoutineProcPtr = Register68kProcPtr;
  70. {$ENDC}
  71.  
  72.     ADBCompletionUPP = UniversalProcPtr;
  73.     ADBDeviceDriverUPP = UniversalProcPtr;
  74.     ADBServiceRoutineUPP = UniversalProcPtr;
  75. {$IFC TYPED_FUNCTION_POINTERS}
  76.     ADBInitProcPtr = PROCEDURE(callOrder: SInt8);
  77. {$ELSEC}
  78.     ADBInitProcPtr = Register68kProcPtr;
  79. {$ENDC}
  80.  
  81.     ADBInitUPP = UniversalProcPtr;
  82.     ADBDataBlockPtr = ^ADBDataBlock;
  83.     ADBDataBlock = PACKED RECORD
  84.         devType:                SInt8;                                    {  original handler ID  }
  85.         origADBAddr:            SInt8;                                    {  original ADB Address  }
  86.         dbServiceRtPtr:            ADBServiceRoutineUPP;                    {  service routine pointer  }
  87.         dbDataAreaAddr:            Ptr;                                    {  this field is passed as the refCon parameter to the service routine  }
  88.     END;
  89.  
  90.     ADBDBlkPtr                            = ^ADBDataBlock;
  91.     ADBSetInfoBlockPtr = ^ADBSetInfoBlock;
  92.     ADBSetInfoBlock = RECORD
  93.         siService:                ADBServiceRoutineUPP;                    {  service routine pointer  }
  94.         siDataAreaAddr:            Ptr;                                    {  this field is passed as the refCon parameter to the service routine  }
  95.     END;
  96.  
  97.     ADBSInfoPtr                            = ^ADBSetInfoBlock;
  98. { ADBOpBlock is only used when calling ADBOp from 68k assembly code }
  99.     ADBOpBlockPtr = ^ADBOpBlock;
  100.     ADBOpBlock = RECORD
  101.         dataBuffPtr:            Ptr;                                    {  buffer: pointer to variable length data buffer  }
  102.         opServiceRtPtr:            ADBServiceRoutineUPP;                    {  completionProc: completion routine pointer  }
  103.         opDataAreaPtr:            Ptr;                                    {  refCon: this field is passed as the refCon parameter to the completion routine  }
  104.     END;
  105.  
  106.     ADBOpBPtr                            = ^ADBOpBlock;
  107. PROCEDURE ADBReInit;
  108.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  109.     INLINE $A07B;
  110.     {$ENDC}
  111. {
  112.     ADBOp has a different interface for 68k assembly than for everything else
  113.     for 68k assembly the interface is 
  114.     #pragma parameter __D0 ADBOp(__A0,__D0)
  115.     OSErr ADBOp( ADBOpBlock * pb, short commandNum );
  116. }
  117. {
  118.     IMPORTANT NOTE:
  119.     "Inside Macintosh: Devices" documents the completion routine for ADBOp will be called with
  120.     four parameters using 68k register based calling conventions, specifically the completion routine
  121.     passed in should be of type ADBServiceRoutineProcPtr. However, when upp types were first added
  122.     to this interface file, the type ADBCompletionUPP was mistakenly used for the second parameter
  123.     to ADBOp. Since applications have shipped using completion routines of type ADBCompletionUPP,
  124.     the mistake cannot be corrected.
  125.     The only difference between ADBServiceRoutineUPP and ADBCompletionUPP is the former takes an extra
  126.     argument which is a pointer to itself, fortunately not needed for PowerPC code.
  127.     For compatibility with existing 68k code, when an ADBOp completion routine is called,
  128.     68k register A1 will point to the completion routine, as documented in Inside Mac.
  129. }
  130. FUNCTION ADBOp(refCon: Ptr; compRout: ADBCompletionUPP; buffer: Ptr; commandNum: INTEGER): OSErr;
  131. FUNCTION CountADBs: INTEGER;
  132.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  133.     INLINE $A077, $3E80;
  134.     {$ENDC}
  135. FUNCTION GetIndADB(VAR info: ADBDataBlock; devTableIndex: INTEGER): ADBAddress;
  136.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  137.     INLINE $301F, $205F, $A078, $1E80;
  138.     {$ENDC}
  139. FUNCTION GetADBInfo(VAR info: ADBDataBlock; adbAddr: ADBAddress): OSErr;
  140.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  141.     INLINE $101F, $205F, $A079, $3E80;
  142.     {$ENDC}
  143. FUNCTION SetADBInfo({CONST}VAR info: ADBSetInfoBlock; adbAddr: ADBAddress): OSErr;
  144.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  145.     INLINE $101F, $205F, $A07A, $3E80;
  146.     {$ENDC}
  147.  
  148. CONST
  149.     uppADBCompletionProcInfo = $007B9802;
  150.     uppADBDeviceDriverProcInfo = $00050802;
  151.     uppADBServiceRoutineProcInfo = $0F779802;
  152.     uppADBInitProcInfo = $00000802;
  153.  
  154. FUNCTION NewADBCompletionProc(userRoutine: ADBCompletionProcPtr): ADBCompletionUPP;
  155.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  156.     INLINE $2E9F;
  157.     {$ENDC}
  158.  
  159. FUNCTION NewADBDeviceDriverProc(userRoutine: ADBDeviceDriverProcPtr): ADBDeviceDriverUPP;
  160.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  161.     INLINE $2E9F;
  162.     {$ENDC}
  163.  
  164. FUNCTION NewADBServiceRoutineProc(userRoutine: ADBServiceRoutineProcPtr): ADBServiceRoutineUPP;
  165.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  166.     INLINE $2E9F;
  167.     {$ENDC}
  168.  
  169. FUNCTION NewADBInitProc(userRoutine: ADBInitProcPtr): ADBInitUPP;
  170.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  171.     INLINE $2E9F;
  172.     {$ENDC}
  173.  
  174. PROCEDURE CallADBCompletionProc(buffer: Ptr; refCon: Ptr; command: LONGINT; userRoutine: ADBCompletionUPP);
  175.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  176.     {To be implemented:  Glue to move parameters into registers.}
  177.     {$ENDC}
  178.  
  179. PROCEDURE CallADBDeviceDriverProc(devAddress: SInt8; devType: SInt8; userRoutine: ADBDeviceDriverUPP);
  180.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  181.     {To be implemented:  Glue to move parameters into registers.}
  182.     {$ENDC}
  183.  
  184. PROCEDURE CallADBServiceRoutineProc(buffer: Ptr; completionProc: TempADBServiceRoutineUPP; refCon: Ptr; command: LONGINT; userRoutine: ADBServiceRoutineUPP);
  185.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  186.     {To be implemented:  Glue to move parameters into registers.}
  187.     {$ENDC}
  188.  
  189. PROCEDURE CallADBInitProc(callOrder: SInt8; userRoutine: ADBInitUPP);
  190.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  191.     {To be implemented:  Glue to move parameters into registers.}
  192.     {$ENDC}
  193. {$ENDC}  {TARGET_OS_MAC}
  194.  
  195. {$ALIGN RESET}
  196. {$POP}
  197.  
  198. {$SETC UsingIncludes := DeskBusIncludes}
  199.  
  200. {$ENDC} {__DESKBUS__}
  201.  
  202. {$IFC NOT UsingIncludes}
  203.  END.
  204. {$ENDC}
  205.